/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.bu.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.bu.dao.BuOrderDao;
import com.thinkgem.jeesite.modules.bu.entity.BuOrder;
import com.thinkgem.jeesite.modules.cms.entity.Site;
import com.thinkgem.jeesite.modules.sys.entity.Office;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;

/**
 * 单表生成Service
 * @author ThinkGem
 * @version 2018-08-26
 */
@Service
@Transactional(readOnly = true)
public class BuOrderService extends CrudService<BuOrderDao, BuOrder> implements IBuOrderService{

	@Resource
	private BuOrderDao buOrderDao;
	
	public BuOrder get(String id) {
		return super.get(id);
	}
	
	@Override
	public BuOrder get(BuOrder buOrder){
		/*User user = UserUtils.getUser();
		buOrder.setOffice(new Office());
		buOrder.getSqlMap().put("dsf", dataScopeFilter(user, "o", "u"));
		buOrder.setSite(new Site());*/
		return buOrderDao.get(buOrder);
	}
	
	public List<BuOrder> findList(BuOrder buOrder) {
		return super.findList(buOrder);
	}
	
	public Page<BuOrder> findPage(Page<BuOrder> page, BuOrder buOrder) {
		User user = UserUtils.getUser();
		buOrder.setOffice(new Office());
		buOrder.getSqlMap().put("dsf", dataScopeFilter(user, "o", "u"));
		buOrder.setSite(new Site());
		return super.findPage(page, buOrder);
	}
	
	@Transactional(readOnly = false)
	public void save(BuOrder buOrder) {
		super.save(buOrder);
	}
	
	@Transactional(readOnly = false)
	public void delete(BuOrder buOrder) {
		super.delete(buOrder);
	}

	@Override
	public Page<BuOrder> findCustomerPage(Page<BuOrder> page, BuOrder buOrder) {
		return super.findCustomerPage(page, buOrder);
	}

	@Override
	public Page<BuOrder> findSupplierPage(Page<BuOrder> page, BuOrder buOrder) {
		return super.findSupplierPage(page, buOrder);
	}

	@Override
	public int selectOrderStatus(BuOrder buOrder) {
		return buOrderDao.selectOrderStatus(buOrder);
	}

	@Transactional(readOnly = false)
	@Override
	public int updateDelivery(BuOrder buOrder) {
		return buOrderDao.updateDelivery(buOrder);
	}

	@Override
	public BuOrder findEntity(BuOrder buOrder) {
		return buOrderDao.findEntity(buOrder);
	}

	@Transactional(readOnly = false)
	@Override
	public int updateBatchReceipt(BuOrder buOrder) {
		return buOrderDao.updateBatchReceipt(buOrder);
	}
	
}